home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Graphics Programming (2nd Edition) / Visual Basic Graphics Programming 2nd Edition.iso / OldSrc / CH7 / SRC / OBJ1LINE.CLS < prev    next >
Encoding:
Text File  |  1995-10-26  |  1.6 KB  |  64 lines

  1. VERSION 1.0 CLASS
  2. BEGIN
  3.   MultiUse = -1  'True
  4. END
  5. Attribute VB_Name = "ObjLine"
  6. Attribute VB_Creatable = False
  7. Attribute VB_Exposed = False
  8. Option Explicit
  9.  
  10. Public x1 As Single
  11. Public y1 As Single
  12. Public x2 As Single
  13. Public y2 As Single
  14.  
  15. Function ObjectType() As String
  16.     ObjectType = "LINE"
  17. End Function
  18.  
  19.  
  20. ' ************************************************
  21. ' Compute the world coordinate bounds for the
  22. ' line.
  23. ' ************************************************
  24. Sub Bound(xmin As Single, ymin As Single, xmax As Single, ymax As Single)
  25.     If x1 < x2 Then
  26.         xmin = x1
  27.         xmax = x2
  28.     Else
  29.         xmin = x2
  30.         xmax = x1
  31.     End If
  32.     If y1 < y2 Then
  33.         ymin = y1
  34.         ymax = y2
  35.     Else
  36.         ymin = y2
  37.         ymax = y1
  38.     End If
  39. End Sub
  40.  
  41. ' ************************************************
  42. ' Write a line to a file using Write.
  43. ' Begin with "LINE" to identify this object.
  44. ' ************************************************
  45. Sub FileWrite(filenum As Integer)
  46.     Write #filenum, "LINE", x1, y1, x2, y2
  47. End Sub
  48. ' ************************************************
  49. ' Draw the line on a Form, Printer, or
  50. ' PictureBox.
  51. ' ************************************************
  52. Sub Draw(canvas As Object)
  53.     canvas.Line (x1, y1)-(x2, y2)
  54. End Sub
  55.  
  56. ' ************************************************
  57. ' Read a line from a file using Input.
  58. ' Assume the "LINE" label has already been read.
  59. ' ************************************************
  60. Sub FileInput(filenum As Integer)
  61.     Input #filenum, x1, y1, x2, y2
  62. End Sub
  63.  
  64.